package reading.common.enums;


/**
 * Project: message-management
 * Package: com.mm.common.enums
 *
 * @author : txw
 * @date : 2018/4/12 18:32
 */
public enum ErrorEnum implements IBaseEnum<ErrorEnum> {
    /**
     * 请求成功或失败错误消息
     */
    SUCCESS("请求成功", 200000),
    REDIRECT("重定向", 300000),
    CLIENT_ERROR("客户端错误", 400000),
    FILE_NOT_FIND("文件没有找到", 4000010),
    PARAMS_NOT_NULL("参数不能为空", 400001),
    DB_ERROR("数据库操作异常", 401001),
    PARAMS_FORMAT_ERROR("参数格式不合法", 400002),
    PARAMS_LENGTH_BEYOND("参数长度超出限制", 400003),
    PARAMS_UNKNOWN("传递未知参数", 400004),
    AUTH_ERROR("认证失败", 403001),
    PRIVILEGE_ERROR("权限不足", 403002),
    SERVER_ERROR("服务端错误", 500000),
    TIME_OUT("响应超时", 500001),
    NOT_FIND_DATA("没有找到数据", 200001),
    NO_INTERFACE("没有该接口", 200003),
    AUTH_BEYOND("越权访问", 400031),
    USER_NAME_NOT_FIND("用户名未找到", 404001),
    PASSWORD_ERROR("密码错误", 404002),
    LOGIN_FAIL("登录失败", 404003),
    LOGIN_SUCCESS("登陆成功", 2000201);

    private String name;
    private int value;

    ErrorEnum(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public static boolean isNull(String str) {
        return str == null || str.trim().length() == 0;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public int getValue() {
        return value;
    }

    @Override
    public ErrorEnum stringOf(String str) {
        return isNull(name) ? ErrorEnum.SUCCESS : ErrorEnum.valueOf(name);
    }
}
